package com.tsunami.auth.controller;

import com.tsunami.auth.service.auth.IRoleAuthorityService;
import com.tsunami.authority.dto.auth.RoleAuthorityQueryDTO;
import com.tsunami.base.R;
import com.tsunami.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Classname RoleAuthorityController
 * @Description TODO
 * @Date 2021-11-01 18:09
 * @Created by lx
 */
@RestController
@RequestMapping("/roleAuthority")
@Api(value = "RoleAuthority", tags = "角色的资源")
public class RoleAuthorityController {
    @Autowired
    private IRoleAuthorityService roleAuthorityService;

    @ApiOperation(value = "查询指定角色关联的菜单和资源", notes = "查询指定角色关联的菜单和资源")
    @GetMapping
    @SysLog("查询指定角色关联的菜单和资源")
    public R page(Integer pageNum,
                  Integer pageSize,
                  String orderByColumn,
                  String isAsc,
                  Long roleId) {
        return roleAuthorityService.selectPageList(roleId);
    }

    @ApiOperation(value = "查询指定角色关联的菜单和资源", notes = "查询指定角色关联的菜单和资源")
    @GetMapping("authority")
    public R authority(Long roleId){
        RoleAuthorityQueryDTO roleAuthorityQueryDTO = roleAuthorityService.authority(roleId);
        return R.ok().data("data",roleAuthorityQueryDTO);
    }
}
